import { Component, ViewChild, OnInit, Inject } from '@angular/core';
import { Router } from '@angular/router';
import { MatSnackBar, MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material';
import { OverlayContainer } from '@angular/cdk/overlay';

import { Content } from './content';
import { AuthService } from './auth.service';
import { BlogService } from './blog.service';
import { AboutMeComponent } from './about-me/about-me.component';
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = "宇坤的博客";
  isDark = false;

  constructor(
    private overlayContainer: OverlayContainer,
    private router: Router,
    public snackBar: MatSnackBar,
    public dialog: MatDialog,
    public authService: AuthService,
    private blogService: BlogService
  ) { }

  ngOnInit() {

  }

  isMobile(): boolean {
    return this.blogService.isMobile();
  }

  openDialog(): void {
    let dialogRef = this.dialog.open(AboutMeComponent);
  }

  toggleTheme(): void {
    this.isDark = !this.isDark;
    if (this.isDark) {
      this.overlayContainer.getContainerElement().classList.add('unicorn-dark-theme');
    } else {
      this.overlayContainer.getContainerElement().classList.remove('unicorn-dark-theme');
    }
  }

  logout(): void {
    this.authService.logout();
    this.snackBar.open("已注销", "", {
      duration: 600,
    });
  }
}

